package com.ysm.smfu;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.umeng.analytics.MobclickAgent;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import com.ysm.smfu.contans.SpKey;
import com.ysm.smfu.utils.ImageUtils;
import com.hyphenate.chat.EMOptions;

import java.util.Map;

import chatuidemo.DemoHelper;
import chatuidemo.utils.PreferenceManager;

//import com.baidu.mapapi.SDKInitializer;


public class BaseApp extends Application {
    private static BaseApp instance;
    // 用于存放倒计时时间
    public static Map<String, Long> map;
    public RefWatcher refWatcher;

    /**
     * 获取上下文实例对象
     *
     * @return
     */
    public static Context getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        EMOptions options = new EMOptions();
        // 默认添加好友时，是不需要验证的，改成需要验证
        options.setAcceptInvitationAlways(false);
        MultiDex.install(this);
        DemoHelper.getInstance().init(this);
        instance = this;
        ImageUtils.init(this);
//        环信声音和震动开启
        PreferenceManager.getInstance().setSettingMsgSound(true);
        PreferenceManager.getInstance().setSettingMsgVibrate(true);
//        LeakCanary检测内存
        refWatcher = SpKey.isDebug ? LeakCanary.install(this) : RefWatcher.DISABLED;
//        腾讯x5浏览器
//        QbSdk.initX5Environment(getApplicationContext(),  null);

        // 将该app注册到微信
//        IWXAPI msgApi = WXAPIFactory.createWXAPI(this, SpKey.WXAPPID, false);
//        msgApi.registerApp(SpKey.WXAPPID);
//        SysUtil.printRespones("注册微信");

//        极光推送
//        JPushInterface.setDebugMode(true);
//        JPushInterface.init(this);

//        友盟分享
        Config.DEBUG = false;
        Config.isJumptoAppStore = true;
        UMShareAPI.get(this);
//      禁止友盟默认的页面统计方式
        MobclickAgent.openActivityDurationTrack(false);

    }

    {
//        PlatformConfig.setWeixin("", "");
        PlatformConfig.setQQZone("1106018364", "FDdoDQGGmJAYWasX");
//        PlatformConfig.setSinaWeibo("", "", "");
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
